
package com.uuah.server.api.transport;

import com.uuah.api.lifecycle.IDisposable;

/**
 *  Combine {@link IMessageDispatching} with various lifecycle methods for the
 * actual instances doing message sending.
 *
 * <p>update record:updator，update time，update content and version</p>
 * @author <a href="jonny_quan@hotmail.com">jonny</a>
 * @date 2009 2009-3-27 上午12:12:43
 * @version 1.0.0
 */
public interface IMessageDispatcher extends IConnectable, IMessageDispatching {

	/**
	 * This method can perform necessary state updates before any of the
	 * {@link IMessageDispatching} methods are invoked.
	 *
	 * @see {@link IMessageDispatcherFactory#activate(com.uuah.server.api.endpoint.UuahEndpoint, MessageDispatcher)}
	 */
	void activate();

	/**
	 * After sending a message, the dispatcher can use this method e.g. to clean
	 * up its internal state (if it has any) or return pooled resources to
	 * whereever it got them during {@link #activate()}.
	 *
	 * @see {@link IMessageDispatcherFactory#passivate(com.uuah.server.api.endpoint.ImmutableEndpoint, MessageDispatcher)}
	 */
	void passivate();

	/**
	 * Determines whether this dispatcher can be reused after message sending.
	 *
	 * @return <code>true</code> if this dispatcher can be reused,
	 *         <code>false</code> otherwise (for example when
	 *         {@link IDisposable#dispose()} has been called because an Exception
	 *         was raised)
	 */
	boolean validate();

	/**
	 * Gets the connector for this dispatcher
	 *
	 * @return the connector for this dispatcher
	 */
	IConnector getConnector();

}
